package com.mobile.learning;


import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.AbstractAction;
import com.markupartist.android.widget.ActionBar.IntentAction;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

public class MainMenuActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
		actionBar.setTitle(R.string.app_name);
		actionBar.setHomeAction(new IntentAction(this, MainMenuActivity
				.createIntent(this), R.drawable.ic_logo));
	}

	public void onButtonClicker(View v) {
		Intent intent;

		switch (v.getId()) {
		case R.id.btnLatihan:
			intent = new Intent(this, LatihanListActivity.class);
			startActivity(intent);
			break;

		case R.id.btnTryout:
			intent = new Intent(this, TryoutListActivity.class);
			startActivity(intent);
			break;

		case R.id.btnLogin:
			intent = new Intent(this, LoginActivity.class);
			startActivity(intent);
			break;
			
		case R.id.btnNilai:
			intent = new Intent(this, HistoryNilaiActivity.class);
			startActivity(intent);
			break;

		case R.id.btnHelp:
			intent = new Intent(this, AboutActivity.class);
			startActivity(intent);
			break;
		default:
			break;
		}
	}

	public static Intent createIntent(Context context) {
		Intent i = new Intent(context, MainMenuActivity.class);
		i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		return i;
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if ((keyCode == KeyEvent.KEYCODE_BACK)) {
			this.finish();
		}
		return super.onKeyDown(keyCode, event);
	}

}
